package org.lem.auth


class LoginEditCommand {
    Long id
    String username
    String password
    String passwordCompare
    Set roles = []

    static constraints = {
        username nullable: false, blank: false, validator: { val, obj ->
            if (ShiroUser.get(obj.id).username != val && ShiroUser.findByUsername(val) != null) {
                return false
            }
        }
        password nullable: false
        roles minSize: 1
        passwordCompare validator: { val, obj ->
            if(val != obj.password) {
                return false
            }
        }
    }
}
